import { Effect, Sink, Stream } from "effect";

//      ┌─── Stream<number, never, never>
//      ▼
const stream = Stream.make(1, 2, 3);

// Create a sink to take the first 2 elements of the stream
//
//      ┌─── Sink<Chunk<number>, number, number, never, never>
//      ▼
const sink = Sink.take<number>(2);

// Run the stream through the sink to collect the elements
//
//      ┌─── Effect<number, never, never>
//      ▼
const sum = Stream.run(stream, sink);

Effect.runPromise(sum).then(console.log);
/*
Output:
{ _id: 'Chunk', values: [ 1, 2 ] }
*/
